package com.ztesoft.huangfu.learning.springboot.springbootrabbitmq.service;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Service;

/**
 * Created with IntelliJ IDEA.
 * Author: huangfu.daohui
 * Date: 2018/5/27
 * Time: 20:50
 * Version: 1.0
 * Description: rabbitm消息接受者
 **/
@Service
@Slf4j
public class RabbitmqService {

    // 消息队列名称：hello
    @RabbitListener(queues = "hello")
    @RabbitHandler
    public void receiveHello(String message) {
        System.out.println("Receiver：" + message);
    }

    @RabbitListener(queues = "neo")
    @RabbitHandler
    public void receiveneo1(String neo1) {
        System.out.println("Receiver Neo1: " + neo1);
    }

    @RabbitListener(queues = "neo")
    @RabbitHandler
    public void receiveneo2(String neo2) {
        System.out.println("Receiver Neo2: " + neo2);
    }

    @RabbitListener(queues = "fanout.A")
    @RabbitHandler
    public void processA(String message) {
        System.out.println("fanout Receiver A  : " + message);
    }

    @RabbitListener(queues = "fanout.B")
    @RabbitHandler
    public void processB(String message) {
        System.out.println("fanout Receiver B: " + message);
    }

    @RabbitListener(queues = "fanout.C")
    @RabbitHandler
    public void processC(String message) {
        System.out.println("fanout Receiver C: " + message);
    }


}
